package com.cadre.web.controller.officer;

import com.cadre.common.utils.R;
import com.cadre.common.utils.annotation.SysLog;
import com.cadre.common.utils.common.GenerateUUID;
import com.cadre.common.utils.oldutil.DateUtil;
import com.cadre.common.utils.oldutil.ValidatorUtils;
import com.cadre.system.domain.officer.B41;
import com.cadre.system.service.B41Service;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;

@Api(value = "单位", tags = {"班子历年运行情况接口"})
@RequestMapping({"/unit/b41"})
@RestController
/* loaded from: B41Controller.class */
public class B41Controller {
    @Autowired
    private B41Service b41Service;

    @GetMapping({"/list"})
    @ApiOperation("获取班子运行情况")
    public R list(@RequestParam("unitId") String unitId) {
        return R.ok().put("data", (Object) this.b41Service.selectList(unitId));
    }

    @GetMapping({"/info/{flowid}"})
    @ApiOperation("获取班子一条班子运行情况")
    public R info(@PathVariable("flowid") String flowid) {
        return R.ok().put("data", (Object) ((B41) this.b41Service.getBaseMapper().selectById(flowid)));
    }

    @PostMapping({"/save"})
    @SysLog(value = "新增运行情况", target = "B01", set = "B41", type = 0)
    @ApiOperation("添加运行情况")
    public R save(@RequestBody B41 b41) {
        b41.setFlowid(GenerateUUID.getUUID());
        this.b41Service.getBaseMapper().insert(b41);
        return R.ok();
    }

    @PostMapping({"/update"})
    @SysLog(value = "修改运行情况", target = "B01", set = "B41", type = 1)
    @ApiOperation("运行情况更新")
    public R update(@RequestBody B41 b41) {
        ValidatorUtils.validateEntity(b41, new Class[0]);
        this.b41Service.getBaseMapper().updateById(b41);
        return R.ok();
    }

    @PostMapping({"/delete"})
    @SysLog(value = "删除运行情况", target = "B01", set = "B41", type = DateUtil.SUB_MONTH)
    @ApiOperation("运行情况删除")
    public R delete(@RequestBody String[] flowids) {
        this.b41Service.getBaseMapper().deleteBatchIds(Arrays.asList(flowids));
        return R.ok();
    }
}
